/**
 * Created with JetBrains WebStorm. User: Administrator Date: 13-10-30 Time:
 * 下午8:06 To change this template use File | Settings | File Templates.
 */
Ext.define('byb.controller.SystemController',{
    extend:"byb.controller.BaseController",
	views: [  'system.AdmUserForm'
	        , 'system.AdmOrgForm'
	        , 'system.AdmLogView'
	        , 'system.MenuTreeView' // 权限TreeView
	        , 'system.AdmUser' // 用户管理
	        , 'system.AdmOrg' // 组织管理
	        , 'system.AdmRole' // 角色管理
	        , 'system.AdmLog' // 角色管理
	        , 'system.AdmOrgTreeViewWindow' // 组织树状结构
	        , 'system.ModifyPassword' // 修改密码
	        ],
	models:['system.AdmUser'
	        ,'system.AdmOrg'
	        ,'system.AdmRole'
	        ,'system.AdmLog'
            ,"system.Company"
            ,"system.Warehouse"
	        ],
	stores:['system.AdmUser'
	        ,'system.AdmOrg'
	        ,'system.AdmRole'
	        ,'system.AdmLog'
	        ,'system.AdmUserCombo'
            ,"system.Company"
            ,"system.Warehouse"
	        ],
	init:function(){
        this.control({
            //日志管理 ==================================
            'sysmgr_logManager button[text=查询]':{ // 用户查询
                click: this.doSearchLog 
            },
            //用户管理 ==================================
            'sysmgr_userManager button[text=查询]':{ // 用户查询
                click: this.doSearchUser 
            },
            'sysmgr_userManagerGrid button[text=导出]':{ // 用户导出
                click: this.doUserExport 
            },
            'sysmgr_userManager button[text=新增]':{ // 用户新增
                click: this.onAddUser 
            },
            'sysmgr_userManager button[text=修改]':{ // 用户修改
                click: this.onUpdateUser 
            },
            'sysmgr_userManager button[text=删除]':{ // 用户删除
                click: this.doDeleteUser 
            },
            'sysmgr_userManager button[text=重置密码]':{ // 用户删除
                click: this.doResetPassword 
            },
//            'admUserForm button[text=取消]':{ // 还原表单数据
//                click: this.doResetUser
//            },
            'admUserForm button[text=保存]':{ // 用户保存
                click: this.doSaveUser 
            },
            'admUserForm button[text=修改]':{ // 用户修改
                click: this.doSaveUser 
            },
            'admUserForm button[text=点击修改]':{ // 弹出组织结构
                click: this.popupOrg
            }
            //组织管理 ==================================
            ,'sysmgr_orgnizeManager button[text=查询]':{ // 组织查询
            	click: this.doSearchOrg
            }
            ,'sysmgr_orgnizeManagerGrid button[text=导出]':{ // 组织查询
            	click: this.doOrgExport
            }
            ,'admOrgForm button[text=保存]':{ // 保存/更新组织 
            	click: this.doAddAdmOrg
            }
            ,'admOrgForm button[text=修改]':{ // 保存/更新组织 
            	click: this.doAddAdmOrg
            }
            ,'admOrgForm button[text=取消]':{ // 取消组织表单信息 
            }
            //角色管理 ==================================
            ,'sysmgr_roleManager button[text=新增]':{ // 角色新增
                click: this.onAddRole
            }
            ,'sysmgr_roleManager button[text=删除]':{ // 删除选中的角色
                click: this.doDeleteRole
            }
            ,'sysmgr_roleManager button[text=保存]':{  // 保存，更新角色
                click: this.doSaveRole
            }
            ,'modifyPassword button[action=itemSave]':{  //更新密码 
                click: this.doModifyPassword
            }
        });
        this.callParent(arguments);
   }
	, onAddUser : function(){
		byb.controller.SystemController.action = null;
		byb.controller.SystemController.reloadAdmRoleStore();
    	Ext.widget('admUserForm');
    	Ext.ComponentQuery.query('admUserForm [name=username]')[0].setReadOnly(false);
    }
	, popupOrg : function(){
    	Ext.widget('admOrgTreeViewWindow');
    }
	, onAddRole : function(){
		Ext.ComponentQuery.query('sysmgr_roleManager form textfield[name=roleName]')[0].allowBlank = true;
		Ext.ComponentQuery.query('sysmgr_roleManager toolbar')[0].disable();
		//取消角色列表的选择状态项
		Ext.ComponentQuery.query('roleListView')[0].getSelectionModel().deselectAll();
		
		byb.controller.SystemController.action = null;
		// 数据初始化
		byb.controller.SystemController.reloadAuthTreeStore(null);
		byb.controller.SystemController.cleanDataForRoleMgr();
		
		Ext.ComponentQuery.query('sysmgr_roleManager form textfield[name=roleName]')[0].allowBlank = false;
    }
	, doUserExport : function(){
		 var form = Ext.ComponentQuery.query('sysmgr_userManager form')[0];
		 form.getForm().standardSubmit=true;
		 form.submit({
             clientValidation: false,
             url:byb.Constant.APIRoot+ "/user/exportUser",
             method: 'POST',
             params: form.getValues()
         });
	}
	, doOrgExport : function(){
		 var form = Ext.ComponentQuery.query('sysmgr_orgnizeManager form')[0];
		 form.getForm().standardSubmit=true;
		 form.submit({
             clientValidation: false,
             url:byb.Constant.APIRoot+ "/org/exportOrg",
             method: 'POST',
             params: form.getValues()
         });
	}
	, doDeleteRole : function(){
		var roleTree = Ext.ComponentQuery.query('roleListView')[0];
		var selectionModel = roleTree.getSelectionModel();
		if (selectionModel.hasSelection()) {
			var records = selectionModel.getSelection()[0];
			if(records.raw.id){
				Ext.Msg.confirm('角色管理 ','是否删除该角色!',function(btn){
    				if(btn === 'yes'){
    					byb.controller.SystemController.cleanDataForRoleMgr();
    					// 提交请求保存
    			        Ext.Ajax.request({
    			            url: byb.Constant.APIRoot+'/role/delete?id=' + records.raw.id,
    			            method:'POST',
    			            success: function(response){
    			            	var obj = Ext.decode(response.responseText);
    			            	if(obj.success){
    			            		byb.controller.SystemController.updateRoleInfo('deleteRole');
    			            		byb.controller.SystemController.cleanDataForRoleMgr();
    			            	}else{
    			            		Ext.Msg.alert('操作提示', '该角色不能删除.');
    			            	}
    			            }
    			        });
    				}
    			});
	    	}
		}else{
			Ext.Msg.alert('操作提示', '未选择角色.');
    	}
    	
    }
	, doModifyPassword : function(){
		var	roleForm =  Ext.ComponentQuery.query('modifyPassword form')[0];
		var	roleData = roleForm.getValues();
		var btn = Ext.getCmp('modifyPasswordBtn');
		if(roleForm.isValid()){
			btn.disable();
			 // 提交请求保存
	        Ext.Ajax.request({
	            url: byb.Constant.APIRoot+'/user/modifyPassword',
	            method:'POST',
	            params:roleData,
	            success: function(response){
	            	var result = JSON.parse(response.responseText);
	            	if( result.results === 1 ){
	            		Ext.Msg.alert('操作提示', '旧密码不正确!');
	            		btn.enable();
	            	}else{
	            		Ext.ComponentQuery.query('modifyPassword')[0].close();
	            	}
	            }
	        });
		}
	}
	, doSaveRole : function(){
		var btn = Ext.getCmp('itemSaveRole');
    	// 角色管理表单
    	var	roleForm =  Ext.ComponentQuery.query('sysmgr_roleManager form')[0];
		// 获取表单数据
		var	roleData = roleForm.getValues();
    	// 检查表单数据
    	if(roleForm.isValid()){
    		var window = Ext.getCmp('myViewPort');
            window.el.mask("请稍等,正在保存数据！", "x-mark-loading");
    		btn.disable();
    		// 获取当前角色分配的权限, 保存在ids
    		var records = Ext.ComponentQuery.query('menuTreeView')[0].getView().getChecked();
	        var ids = [];
	        Ext.Array.each(records, function(rec){
	        	if(rec.raw.data.id){
	        		ids.push(rec.raw.data.id);
	        	}
	        });
	    
	        roleData['resIds'] = ids.join(',');
	        
	        // 提交请求保存
	        Ext.Ajax.request({
	            url: byb.Constant.APIRoot+'/role/save',
	            method:'POST',
	            params:roleData,
	            success: function(response){
	            	var result = JSON.parse(response.responseText);
	            	if( result.results === 1 ){
	            		Ext.Msg.alert('操作提示', '该角色已存在!');
	            	}else{
	            		var action = byb.controller.SystemController.action;
	            		byb.controller.SystemController.updateRoleInfo('updateRole');
	            		if(action !== 'modifyRole'){
		            		//取消角色列表的选择状态项
		            		Ext.ComponentQuery.query('roleListView')[0].getSelectionModel().deselectAll();
		            		byb.controller.SystemController.cleanDataForRoleMgr();
	            		}
	            	}
	            	
	            	window.el.unmask();
	            	btn.enable();
	            }
	        });
    	}
    }
	, doSaveUser : function(){
		var btn = Ext.getCmp('itemSaveUser');
		// 用户表单
		var	userForm =  Ext.ComponentQuery.query('admUserForm form')[0];
		var	data = userForm.getValues();
		
		if(userForm.isValid()){
			btn.disable();
			//用户表单数据
			var container = Ext.getCmp("admUserMgr_assignRole");
			var checkgroup = container.query("[name=rolesForUser_checkboxgrp][checked=true]");
			var roleIds = [];
			for(i in checkgroup){
				roleIds.push(checkgroup[i].inputValue);
			}
			data['roleIds'] = roleIds.join(',');
			data['birthday'] = data.birthdaySrc;
			
			  // 提交请求保存
	        Ext.Ajax.request({
	            url: byb.Constant.APIRoot+'/user/save',
	            method:'POST',
	            params:data,
	            success: function(response){
		    	    btn.enable();
	            }
	        });
		}
	}
	, onUpdateUser : function(context, e, eOpts) {
		var records = byb.controller.SystemController.getSelectedModelRecordsForUserGrid();
		if(!records){
			Ext.Msg.alert('操作提示','请选择要修改的用户!');
		}else{
			byb.controller.SystemController.initDataForUpdateUser();
		}
	}
	
	, doDeleteUser: function(context, e, eOpts) {
		var records = byb.controller.SystemController.getSelectedModelRecordsForUserGrid();
		if (records) {
			Ext.Msg.confirm('用户管理 ','是否删除用户!',function(btn){
				if(btn === 'yes'){
					var id = records.data.id;
					  // 提交请求保存
			        Ext.Ajax.request({
			            url: byb.Constant.APIRoot+'/user/delete?id=' + id,
			            method:'GET',
			            async: false,
			            success: function(response){
			               //获取分页数据,用于处是是否跳转到上一页
			         	   var pagintoolbarStore = Ext.ComponentQuery.query('sysmgr_userManagerGrid pagingtoolbar')[0].store;
			         	   var currentPage =pagintoolbarStore.currentPage;
			         	   var totalCount =pagintoolbarStore.totalCount;
			         	   var pageSize =pagintoolbarStore.pageSize;
			         	   if(totalCount % pageSize == 1 && currentPage > 1){
			         		  Ext.ComponentQuery.query('sysmgr_userManagerGrid pagingtoolbar')[0].movePrevious();
			         	   }else{
				               var store = Ext.ComponentQuery.query('sysmgr_userManagerGrid')[0].getStore();
			    	       	   store.reload();
			         	   }
			            }
			        });
			        //默认选择第一个, 树显示有点问题
			        //Ext.ComponentQuery.query('roleListView')[0].select(0);
			        //Ext.ComponentQuery.query('roleListView')[0].fireEvent('itemclick', Ext.ComponentQuery.query('roleListView')[0], Ext.ComponentQuery.query('roleListView')[0].getSelectionModel().getSelection()[0],null,0);
				}
			});
		}else{
			Ext.Msg.alert('操作提示','请选择要删除的用户!');
		}
	}
	, doResetPassword : function(){
		var records = byb.controller.SystemController.getSelectedModelRecordsForUserGrid();
		if (records) {
			Ext.Msg.confirm('用户管理 ','是否为该用户重置密码!',function(btn){
				if(btn === 'yes'){
					var id = records.data.id;
					  // 提交请求保存
			        Ext.Ajax.request({
			            url: byb.Constant.APIRoot+'/user/resetPassword?id=' + id,
			            method:'POST',
			            success: function(response){
			               var store = Ext.ComponentQuery.query('sysmgr_userManagerGrid')[0].getStore();
		    	       	   store.reload();
			            }
			        });
				}
			});
		}else{
			Ext.Msg.alert('操作提示','请选择要重置密码的用户!');
		}
	}
	, doSearchLog : function(context, e, eOpts){
		 var condition = Ext.ComponentQuery.query('sysmgr_logManager form')[0].getValues();
		 var store = Ext.ComponentQuery.query('sysmgr_logManagerGrid')[0].getStore();
		 store.getProxy().setExtraParam("condition", Ext.encode(condition));
		 Ext.ComponentQuery.query('sysmgr_logManagerGrid pagingtoolbar')[0].moveFirst();
	}
	, doSearchUser : function(context, e, eOpts){
		 var condition = Ext.ComponentQuery.query('sysmgr_userManager form')[0].getValues();
		 var store = Ext.ComponentQuery.query('sysmgr_userManagerGrid')[0].getStore();
		 store.getProxy().setExtraParam("condition", Ext.encode(condition));
		 Ext.ComponentQuery.query('sysmgr_userManagerGrid pagingtoolbar')[0].moveFirst();
	}
	, doSearchOrg: function(context, e, eOpts){
		 var condition = Ext.ComponentQuery.query('sysmgr_orgnizeManager form')[0].getValues();
		 var store = Ext.ComponentQuery.query('sysmgr_orgnizeManagerGrid')[0].getStore();
		 store.getProxy().setExtraParam("condition", Ext.encode(condition));
		 Ext.ComponentQuery.query('sysmgr_orgnizeManagerGrid pagingtoolbar')[0].moveFirst();
	}
    // 保存组织信息
	, doAddAdmOrg : function(context, e, eOpts){
		var btn = Ext.getCmp('btnSaveOrg');
		// 角色管理表单
    	var	orgForm =  Ext.ComponentQuery.query('admOrgForm form')[0];
		// 获取表单数据
		var	orgData = orgForm.getValues();
		//父组织ID
		var records = byb.controller.SystemController.getSelectedModelRecordsForOrgTreeView();
		if(records){
			orgData['parentOrgTypeId'] = records.raw.id;
		}
    	// 检查表单数据
    	if(orgForm.isValid()){
    		btn.disable();
	        // 提交请求保存
	        Ext.Ajax.request({
	            url: byb.Constant.APIRoot+'/org/save',
	            method:'POST',
	            params:orgData,
	            success: function(response){
	            	var result = JSON.parse(response.responseText);
	            	if(result.results === 1){
	            		Ext.Msg.alert('操作提示', '组织名称在同一公司内唯一!');
	            	}else if(result.results === 2){
	            		Ext.Msg.alert('操作提示', '组织编码在同一公司内唯一!');
	            	}else if(result.results === 3){
	            		Ext.Msg.alert('操作提示', '组织名称在集团内唯一!');
	            	}else if(result.results === 4){
	            		Ext.Msg.alert('操作提示', '组织编码在集团内唯一!');
	            	}else{
	            		byb.controller.SystemController.updateOrgInfo();
	 	    		   	btn.enable();
	            	    Ext.ComponentQuery.query('admOrgForm')[0].close();
		            	byb.controller.SystemController.refreshCompany();
	            	    return;
	            	}
	    		   btn.enable();
	            }
	        });
    	}
	}
	//初始化用户Form表单
	, doResetUser : function(){
		byb.controller.SystemController.initDataForUpdateUser();
	}
	//静态方法
	,  statics: {
		 userForm 	: null
		 , action	: null //获取当前操作动作: 主要用于用户更新和保存共用一个界面，用来区分当前界面是新增还是保存
		 , orgId    : null
		 , loginUserOrgCode	: null //当前登录用户组织code
		 //获取用户Widet组件
		 ,getUserForm : function(){
			 if(this.userForm){
				this.userForm.destroy(); 
			 }
			 
			 this.userForm =  Ext.widget("admUserForm");
			 
			 return this.userForm;
		 }
        //返回查询用户列表选择行的记录
        ,getSelectedModelRecordsForUserGrid: function(){
        	var gridPanel = Ext.ComponentQuery.query('sysmgr_userManagerGrid')[0];
    		var selectionModel = gridPanel.getSelectionModel();
    		if (selectionModel.hasSelection()) {
    			var select = selectionModel.getSelection()[0];
    			selectionModel.deselectAll();
    			selectionModel.select(select.index % 25);
    			return select;
    		}else{
        		return null;
        	}
        }
        //返回组织树选择节点的记录
        ,getSelectedModelRecordsForOrgTreeView: function(){
        	var orgTreeView = Ext.ComponentQuery.query('admOrgTreeView')[0];
    		var selectionModel = orgTreeView.getSelectionModel();
    		if (selectionModel.hasSelection()) {
    			return selectionModel.getSelection()[0];
    		}else{
        		return null;
        	}
        }
        ,initDataForUpdateUser : function(){
        	var flag = false;
    		//设置当前操作, 用于RoleGridView
        	this.action = 'modifyUser';
        	var records = this.getSelectedModelRecordsForUserGrid();
    		if (records) {
    			var view = this.getUserForm();
    			view.setTitle('修改用户');
    			var button = view.down("button[action=itemSave]");
    			button.setText("修改");
    			view.down('[name=username]').setReadOnly(true);
      			view.down("form").loadRecord(records);
    		}
        }
        //组织管理--------------------------------
        //弹出新增组织窗口
        ,onAddOrg : function(){
        	var records = this.getSelectedModelRecordsForOrgTreeView();
        	if(records){
        		var view = Ext.widget('admOrgForm');
	        	var departmentType = view.down("combobox[name=subOrgnizeTypeId]");
				var orgType = records.raw.data.orgType;
				if('DEPARTMENT' === orgType || 'COMPANY' === orgType){
					var depart = view.down('form combobox[name=subOrgnizeTypeId]');
		        	var store = depart.getStore();
		    		store.getProxy().setExtraParam("companyId",records.raw.data.id);
		    		store.reload();
					departmentType.show();
				}else{
					departmentType.hide();
				}
				
				Ext.ComponentQuery.query('admOrgForm form textfield[name=code]')[0].setReadOnly(false);
        	}
        }
        //弹出修改组织窗口
        ,onUpdateOrg : function(){
        	//设置当前操作, 用于RoleGridView
        	var records = this.getSelectedModelRecordsForOrgTreeView();
        	if(records){
				var view = Ext.widget('admOrgForm');
				var button = view.down("button[action=itemSave]");
				button.setText("修改");

	        	var depart = view.down('form combobox[name=subOrgnizeTypeId]');
	        	var store = depart.getStore();
	    		store.getProxy().setExtraParam("companyId",records.raw.data.id);
	    		store.reload();
				
				var departmentType = view.down("combobox[name=subOrgnizeTypeId]");
				var orgType = records.raw.data.orgType;
				if('DEPARTMENT' === orgType){
					departmentType.show();
				}else{
					departmentType.hide();
				}

				Ext.Ajax.request({
			            url: byb.Constant.APIRoot+'/org/get?id=' + records.raw.id,
			            method:'GET',
			            success: function(response){
			            	var obj = Ext.decode(response.responseText);
			                if (obj && obj.hasOwnProperty("results")) {
			                  var instance = Ext.create('byb.model.system.AdmOrg', obj.results);
			                  var setupDate = null;
			                  if(instance.raw.setupDate){
			                	  setupDate = new Date(instance.raw.setupDate);
			                  }
			                  var subOrgId = null;
			                  if(instance.raw.orgSubType){
			                	  subOrgId = instance.raw.orgSubType.id;
			                  }
			        		  view.down('form textfield[name=id]').setValue(instance.raw.id);
			        		  view.down('form textfield[name=name]').setValue(instance.raw.name);
			        		  view.down('form textfield[name=code]').setValue(instance.raw.code);
			        		  view.down('form textfield[name=code]').setReadOnly(true);
			        		  depart.setValue(subOrgId);
			        		  view.down('form datefield[name=setupDate]').setValue(setupDate);
			        		  view.down('form textfield[name=contact]').setValue(instance.raw.contact);
			        		  view.down('form textfield[name=contactPhone]').setValue(instance.raw.contactPhone);
			        		  view.down('form textarea[name=address]').setValue(instance.raw.address);
			        		  view.down('form textarea[name=remark]').setValue(instance.raw.remark);
			                }
			            }
			    });
        	}
        }
    	//删除组织
    	, doDeleteOrg: function(context, e, eOpts) {
    	   var records = this.getSelectedModelRecordsForOrgTreeView();

    	   //获取分页数据,用于处是是否跳转到上一页
    	   var pagintoolbarStore = Ext.ComponentQuery.query('sysmgr_orgnizeManagerGrid pagingtoolbar')[0].store;
    	   var currentPage =pagintoolbarStore.currentPage;
    	   var totalCount =pagintoolbarStore.totalCount;
    	   var pageSize =pagintoolbarStore.pageSize;
    	   var goPrepage = false;
        	   
    		if (records && records.raw.id) {
    			Ext.Msg.confirm('组织管理 ','是否删除组织!',function(btn){
    				if(btn === 'yes'){
    					  // 提交请求保存
    			        Ext.Ajax.request({
    			            url: byb.Constant.APIRoot+'/org/delete?id=' + records.raw.id,
    			            method:'GET',
    			            success: function(response){
    			         	   if(totalCount % pageSize == 1 && currentPage > 1){
    			         		  goPrepage = true;
    			         	   }
    			            	byb.controller.SystemController.refreshCompany();
    			            	byb.controller.SystemController.updateOrgInfo(goPrepage);
    			            }
    			        });
    				}
    			});
    		}else{
    			
    		}
    	}
    	//更新组织查询界面和树的信息
    	,updateOrgInfo:function(goPrepage){
    	   //更新组织树信息
           var store = Ext.ComponentQuery.query('admOrgTreeView')[0].getStore();
       	   store.reload();
       	   //更新组织查询信息
       	   if(goPrepage){
       		   Ext.ComponentQuery.query('sysmgr_orgnizeManagerGrid pagingtoolbar')[0].movePrevious();
       	   }else{
	       	   store = Ext.ComponentQuery.query('sysmgr_orgnizeManagerGrid')[0].getStore();
	       	   store.reload();
       	   }
    	}
    	//更新角色管理信息
    	,updateRoleInfo:function(action){
	       	this.reloadAdmRoleStore();
    		if('updateRole' !== action){
    			this.reloadAuthTreeStore();
    		}
	    //角色管理 做新增和删除，清空数据
    	},cleanDataForRoleMgr: function(){
    		Ext.ComponentQuery.query('sysmgr_roleManager form textfield[name=roleName]')[0].allowBlank = true;
    		Ext.ComponentQuery.query('sysmgr_roleManager form textfield[name=id]')[0].setValue(null);
    		Ext.ComponentQuery.query('sysmgr_roleManager form textfield[name=roleName]')[0].setValue(null);
    		Ext.ComponentQuery.query('sysmgr_roleManager form textfield[name=discription]')[0].setValue(null);
    		Ext.ComponentQuery.query('sysmgr_roleManager form textfield[name=roleName]')[0].allowBlank = false;
    	}
    	//重新权限树Store
    	, reloadAuthTreeStore:function(id){
    		var authTreeView = Ext.ComponentQuery.query('menuTreeView')[0];
    		//authTreeView.collapseAll();
    		var store = authTreeView.getStore();
    		store.getProxy().setExtraParam("id",id);
    		store.reload({
    			callback: function(){
	    			Ext.ComponentQuery.query('sysmgr_roleManager toolbar')[0].enable();
	    			Ext.ComponentQuery.query('roleListView')[0].enable();
    			}
    		});
    	}
    	//更新用户Store
    	,reloadAdmUserStore:function(){
    		//...
    	}
    	//更新角色Store
    	,reloadAdmRoleStore:function(){
    		var roleList = Ext.ComponentQuery.query('roleListView')[0];
    		if(roleList){
	    		roleList.getStore().reload();
    		}
    		var roleGrid = Ext.ComponentQuery.query('roleGridView')[0];
    		if(roleGrid){
    			roleGrid.getStore().reload();
    		}
    	}
    	//密码修改
    	,onModifyPassword:function(){
    		Ext.widget("modifyPassword");
    	}
        , showMessageIn: function(messager) {
            Ext.get("gaojingwindow").show = 1;
            Ext.create('Ext.fx.Anim', {
                target: Ext.get('gaojingwindow'),
                duration: 600,
                from: {
                    opacity: 0.3,       // Opaque
                    'margin-top': '-65px' //starting width 400
                },
                to: {
                    opacity: 1,       // Opaque
                    'margin-top': '0px'
                }
            });

        }
        , showMessageOut: function(messager) {
            Ext.get("gaojingwindow").show = 0;
            Ext.create('Ext.fx.Anim', {
                target: Ext.get('gaojingwindow'),
                duration: 600,
                from: {
                    opacity: 1,       // Opaque
                    'margin-top': '0px' //starting width 400
                },
                to: {
                    opacity: 0.3,       // Opaque
                    'margin-top': '-65px'
                }
            });

        }
    	, refreshCompany : function(){
    		var company = Ext.ComponentQuery.query('TopView combo[name=companyId]')[0];
        	if(company && company.getStore()){
        		company.getStore().reload();
        	}
    	}
    }
   
});
